﻿$(function() {
	$("#openlogin").button({
		icons: {primary: "ui-icon-check"}
		
	}).click(function(){
		 var div = 
			 $("<div/>").attr("id","formCadastro")
			 	.append($("<label/>").text("Nome: "))
			 		.append($("<input/>").attr("type","text")
			 				.attr("id","name"))
			 	.append("<br />")
			 	.append($("<label/>").text("email: "))
			 		.append($("<input/>").attr("type","text")
			 				.attr("id","email"))
			 	.append("<br />")
			 	.append($("<label/>").text("Endereço: "))
			 		.append($("<input/>").attr("type","text")
			 				.attr("id","address"))
			 	.append("<br />")
			 	.append($("<label/>").text("CEP: "))
			 		.append($("<input/>").attr("type","text")
			 				.attr("id","zipCode"))
			 	.append("<br />")
			 	.append($("<label/>").text("Documento: "))
			 		.append($("<input/>").attr("type","text")
			 				.attr("id","document"))
			 	.append("<br />")
			 	.append($("<label/>").text("Data de Nascimento: "))
			 		.append($("<input/>").attr("type","text")
			 				.attr("id","brithDate"))
			 	.append("<br />")
			 	.append($("<label/>").text("Senha: "))
			 		.append($("<input/>").attr("type","password")
			 				.attr("id","password"))
			 	.append("<br />")
			 	
			$(div).dialog({
					title: "Login",
					modal: true,
					height: 460,
					width: 300,
					buttons: {
						"Cadastrar-se agora": function(){
							
							login($("#name").val(),
									$("#email").val(),
									$("#address").val(),
									$("#zipCode").val(),
									$("#document").val(),
									$("#birthDate").val(),
									$("#password").val(),
									function(resp){
										if(resp == "1"){
											alert("Cadastro efetuado com sucesso")
										}else{
											alert("O Cadastro não foi efetuado com sucesso")
										}
									}, 
									function(){})
						}
					},
					close: function(){
						$(this).remove();
					}
					
				})
			})
		})